import { defineStore } from 'pinia'

export const globalStore = defineStore('global', {
  state: () => ({
    showLoading: false,
    agreePolicy: false,
    isTimetableListView: true
  }),
  actions: {
    setLoading(e) {
      this.showLoading = e
    },
    setAgreePolicy(e) {
      this.agreePolicy = e
    },
    setIsTimetableListView(e) {
      this.isTimetableListView = e
    }
  },
  persist: {
    enabled: true,
    strategies: [
      {
        key: 'agreePolicy',
        paths: ['agreePolicy'],
        storage: localStorage
      },
      {
        key: 'isTimetableListView',
        paths: ['isTimetableListView'],
        storage: localStorage
      }
    ]
  }
})
